﻿using System;
using System.Collections.Generic;
using System.Xml.Serialization;

namespace Data.Realm
{
    [Serializable]
    [XmlType("r")]
    public class Point
    {
        [XmlAttribute]
        public int x { get {return directions[current].Key;}}
        [XmlAttribute]
        public int y { get { return directions[current].Value; } }

        static Random rnd = new Random();

        [XmlIgnore()]
        public int current;
        private static KeyValuePair<int, int>[] directions;

        static Point()
        {
            directions = new KeyValuePair<int, int>[4];
            directions[0] = new KeyValuePair<int, int>(0, 1);
            directions[1] = new KeyValuePair<int, int>(-1, 0);  
            directions[2] = new KeyValuePair<int, int>(0, -1);
            directions[3] = new KeyValuePair<int,int>(1,0);
                
        }
        public Point()
        {
            current = rnd.Next() % 4;
        }

        public int GetIntDirection()
        {
            return current;
        }

        public void RotateClockwaise() 
        {
            current = (current + 3) % 4;
        }

        public void RotateCounterClockwaise() 
        {
            current = (current + 1) % 4;
        }
    }
}
